﻿@using Himall.Core;
@model Himall.Web.Models.ShopModel
@{
    ViewBag.Title = "Details";
}
<link rel="stylesheet" type="text/css" href="~/Content/bootstrap-datetimepicker.min.css">
<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <li class="active"><a>店铺信息</a></li>
    </ul>
    <form class="form-horizontal" id="from_Save" role="form">
        <h3 class="table-hd">公司及联系人信息</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>公司名称</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.CompanyName, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.CompanyName)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>公司所在地</td>
                    <td>

                        <div class="col-sm-6">
                            <span id="span_area">
                                <span id="span_province"><select id="companyLocationProvince" class="form-control input-sm select-sort"><option value="">请选择：</option></select></span>
                                <span id="span_city"><select id="companyLocationCity" class="form-control input-sm select-sort"><option value="">请选择：</option></select></span>
                                <span id="span_county"><select id="companyLocationDistrict" class="form-control input-sm select-sort"><option value="">请选择：</option></select></span>
                            </span>
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.NewCompanyRegionId)
                        </div>
                        @Html.TextBoxFor(item => item.NewCompanyRegionId, new { style = "width:0px;height:0px;border-width:0px;" })
                    </td>
                </tr>
                <tr>
                    <td>公司详细地址</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.CompanyAddress, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.CompanyAddress)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>公司电话</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.CompanyPhone, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.CompanyPhone)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>员工总数</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.DropDownListFor(item => item.CompanyEmployeeCount, (IEnumerable<SelectListItem>)Himall.Model.CompanyEmployeeCount.LessThanFive.ToSelectList(), new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.CompanyEmployeeCount)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>注册资金</td>
                    <td>
                        <div class="col-sm-3">
                            @(Html.TextBoxFor(item => item.CompanyRegisteredCapital, new { @class = "form-control input-sm" }))
                        </div>
                        <div class="col-sm-1" style="line-height:30px">万元</div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.CompanyRegisteredCapital)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>联系人姓名</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.ContactsName, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.ContactsName)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>联系人电话</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.ContactsPhone, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.ContactsPhone)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>电子邮箱</td>
                    <td>
                        <div class="col-sm-3">
                            @Html.TextBoxFor(item => item.ContactsEmail, new { @class = "form-control input-sm" })
                        </div>
                        <div class="col-sm-3">
                            @Html.ValidationMessageFor(item => item.ContactsEmail)
                        </div>
                    </td>
                </tr>
				<tr>
                    <td>经营许可类证书</td>
                    <td>
                        <div class="form-group upload-img" id="BusinessLicenseCert"></div>
                    </td>
                </tr>
				<tr>
                    <td>产品类证书</td>
                    <td>
                        <div class="form-group upload-img" id="ProductCert"></div>
                    </td>
                </tr>
				<tr>
                    <td>其它证书</td>
                    <td>
                        <div class="form-group upload-img" id="OtherCert"></div>
                    </td>
                </tr>
				
				
            </tbody>
        </table>

        <h3 class="table-hd">营业执照信息（副本）</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>营业执照号</td>
                    <td>@Model.BusinessLicenceNumber</td>
                </tr>
                <tr>
                    <td>营业执照所在地</td>
                    <td>@Model.BusinessLicenceRegionId</td>
                </tr>
                <tr>
                    <td>营业执照有效期</td>
                    <td>
                        @if (Model.BusinessLicenceStart.HasValue)
                        {
                            @Model.BusinessLicenceStart.Value.ToShortDateString()
                        }
                        -
                        @if (Model.BusinessLicenceEnd.HasValue)
                        {
                            @Model.BusinessLicenceEnd.Value.ToShortDateString()
                        }
                    </td>
                </tr>
                <tr>
                    <td>法定经营范围</td>
                    <td>@Model.BusinessSphere</td>
                </tr>
                <tr>
                    <td>法定代表人</td>
                    <td>@Model.legalPerson</td>
                </tr>
                <tr>
                    <td>公司成立日期</td>
                    <td>@Model.CompanyFoundingDate.Value.ToString("yyyy-MM-dd")</td>
                </tr>
                <tr>
                    <td>营业执照号<br />电子版</td>
                    <td><img style="max-width:700px" src="@Model.BusinessLicenceNumberPhoto" alt="" /></td>
                </tr>
            </tbody>
        </table>

        <h3 class="table-hd">组织机构代码证</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>组织机构代码</td>
                    <td>@Model.OrganizationCode</td>
                </tr>
                <tr>
                    <td>组织机构代码证<br />电子版</td>
                    <td><img style="max-width:700px" src="@Model.OrganizationCodePhoto" alt="" /></td>
                </tr>
            </tbody>
        </table>

        <h3 class="table-hd">一般纳税人证明</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>一般纳税人证明</td>
                    <td><img style="max-width:700px" src="@Model.GeneralTaxpayerPhot" alt="" /></td>
                </tr>
            </tbody>
        </table>

        <h3 class="table-hd">结算账号信息</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>银行开户名</td>
                    <td>@Model.BankAccountName</td>
                </tr>
                <tr>
                    <td>公司银行账号</td>
                    <td>@Model.BankAccountNumber</td>
                </tr>
                <tr>
                    <td>开户银行支行名称</td>
                    <td>@Model.BankName</td>
                </tr>
                <tr>
                    <td>支行联行号</td>
                    <td>@Model.BankCode</td>
                </tr>
                <tr>
                    <td>开户银行所在地</td>
                    <td>@Model.BankRegionId</td>
                </tr>
                <tr>
                    <td>开户银行许可证<br />电子版</td>
                    <td><img style="max-width:700px" src="@Model.BankPhoto" alt="" /></td>
                </tr>
            </tbody>
        </table>

        <h3 class="table-hd">税务登记证</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>税务登记证号</td>
                    <td>@Model.TaxRegistrationCertificate</td>
                </tr>
                <tr>
                    <td>纳税人识别号</td>
                    <td>@Model.TaxpayerId</td>
                </tr>
                <tr>
                    <td>税务登记证号<br />电子版</td>
                    <td><img style="max-width:700px" src="@Model.TaxRegistrationCertificatePhoto" alt="" /></td>
                </tr>
            </tbody>
        </table>

        <h3 class="table-hd">店铺经营信息</h3>
        <table class="table table-bordered table-striped">
            <colgroup>
                <col class="col-xs-1">
                <col class="col-xs-7">
            </colgroup>
            <tbody>
                <tr>
                    <td>卖家帐号</td>
                    <td>@Model.Account</td>
                </tr>
                <tr>
                    <td>店铺名称</td>
                    <td>@Model.Name</td>
                </tr>
                <tr>
                    <td>店铺等级</td>
                    <td>@Model.ShopGrade</td>
                </tr>
                <tr>
                    <td>经营类目</td>
                    <td>
                        @foreach (var item in Model.BusinessCategory)
                        {
                            <b>@item.Name ,</b>
                        }
                    </td>
                </tr>
                @if (File.Exists(Server.MapPath(Model.PayPhoto)))
                {
                    <tr>
                        <td>付款凭证</td>
                        <td><img style="max-width:700px" src="@Model.PayPhoto" alt="" /></td>
                    </tr>
                }
                <tr>
                    <td>付款凭证说明</td>
                    <td>@Model.PayRemark</td>
                </tr>
            </tbody>
        </table>

        <div class="form-group" style="padding:20px 0 100px">
            <div class="col-sm-offset-2 col-sm-10">
                <a class="btn btn-primary" id="Save" href="javascript:;">保 存</a>
            </div>
        </div>
    </form>
</div>
<script src="~/Scripts/Region.js"></script>
<script src="~/Scripts/RegionBind.js"></script>
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="~/Scripts/jquery.hishopUpload.js"></script>
<script src="~/Scripts/jquery.himallLinkage.nocreate.js"></script>
<script src="~/Scripts/autoNumeric.js"></script>
<script type="text/javascript">
    var companyRegionIds = "@ViewBag.CompanyRegionIds";

    $(function () {
        $('#Save').click(function () {
            var form = $('#from_Save');
            if (form.valid()) {

                $('#CompanyRegisteredCapital').val($('#CompanyRegisteredCapital').val().replace(/,/g, ''));
                if (isSelectAddr($("#companyLocationProvince"), $("#companyLocationCity"), $("#companyLocationDistrict")))
                {
                    var region= $("#companyLocationDistrict").val()==0 ? $("#companyLocationCity").val():$("#companyLocationDistrict").val();
                    $('#NewCompanyRegionId').val(region);
                }
                var data = form.serialize();

                //data=data+'&CompanyRegionId='
                var loading = showLoading();
                $.post('EditProfile1', data, function (result) {
                    loading.close();
                    if (result.success)
                    {
                        $.dialog.tips('保存成功！');
                        window.location.reload();
                    }
                    else
                        $.dialog.errorTips('保存失败！' + result.msg);
                });
            }
        });

        var businessLicenseCerts = @Html.Raw(Json.Encode(@ViewBag.BusinessLicenseCerts));
        var productCerts = @Html.Raw(Json.Encode(@ViewBag.ProductCerts));
        var otherCerts = @Html.Raw(Json.Encode(@ViewBag.OtherCerts));
       
        $("#BusinessLicenseCert").hishopUpload({
            title: '经营许可类证书:(最多三张)',
            imageDescript: '',
            displayImgSrc: businessLicenseCerts,
            imgFieldName: "BusinessLicenseCert",
            defaultImg: '/Images/default_100x100.png',
            imagesCount: 3,
            dataWidth: 6
        });
        $("#ProductCert").hishopUpload({
            title: '产品类证书:(最多三张)',
            imageDescript: '',
            displayImgSrc: productCerts,
            imgFieldName: "ProductCert",
            defaultImg: '/Images/default_100x100.png',
            imagesCount: 3,
            dataWidth: 6
        });
        $("#OtherCert").hishopUpload({
            title: '其它证书:(最多三张)',
            imageDescript: '',
            displayImgSrc: otherCerts,
            imgFieldName: "OtherCert",
            defaultImg: '/Images/default_100x100.png',
            //pictureSize: '100*100',
            imagesCount: 3,
            dataWidth: 6
        });
        //var businessLicenseCert = $("#BusinessLicenseCert").hishopUpload('getImgSrc').toString()
        
        //$('#CompanyRegisteredCapital').autoNumeric({vMax:999999});

        setProvince($("#companyLocationProvince"), $("#companyLocationCity"), $("#companyLocationDistrict"));
        InitRegion($("#companyLocationProvince"), $("#companyLocationCity"), $("#companyLocationDistrict"),companyRegionIds);
    });

    function bindCity(provinceControl, cityControl, countyControl, regionId) {
        var regions = regionId.split(',');
        var shengfen = regions.length > 0 ? regions[0] : 0;
        var city = regions.length > 1 ? regions[1] : 0;
        var county = regions.length > 2 ? regions[2] : 0;
        $('#' + provinceControl + ',#' + cityControl + ',#' + countyControl).cityLink(shengfen, city, county);
    }

</script>

<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
